package fr.ssd.sic.imap;

import javax.mail.Folder;
import javax.mail.MessagingException;
import javax.swing.tree.DefaultMutableTreeNode;

public class ListFoldersCmd {

	public ListFoldersCmd(){
		
	}
	
	public void execute(DefaultMutableTreeNode tree, Folder folder) throws MessagingException{
		tree.setUserObject(folder);
		Folder[] folders = folder.list();
		  for(Folder f : folders){
			  DefaultMutableTreeNode subTree = new DefaultMutableTreeNode();
			  tree.add(subTree);
			  execute(subTree, f);
		  }
	}
}
